@extends('layouts.app', ['active' => 2])

@section('style')
<link href="{{ asset('plugin/datepicker/css/foundation-datepicker.css') }}" rel="stylesheet" type="text/css">
<link href="{{ asset('plugin/validation/dist/css/formValidation.css') }}" rel="stylesheet" type="text/css"/>
<link href="{{ asset('plugin/validation/css/default.css') }}" rel="stylesheet" type="text/css"/>
@endsection
@section('title')修改密码 -
@endsection

@section('content')
            <div class="panel panel-default">
                <div class="panel-heading"><i class="fa fa-pencil-square-o" aria-hidden="true"></i> 修改密码

                    @include('user.menu',['active' => 0])</div>
                <div class="panel-body">

                    @if (count($errors) > 0)
                        <div class="alert alert-danger">

                            {!! implode('<br/>', $errors->all()) !!}
                        </div>
                    @endif

                        <form class="form-horizontal" id="validateForm" action="{{ url('user')  . '/' . $user->id  }}" method="POST" enctype="multipart/form-data">
                            {!! csrf_field() !!}
                            {!! method_field('put') !!}
                            <div class="form-group">
                                <label for="name" class="col-sm-2 control-label">账号</label>
                                <div class="col-sm-10">
                                    <input type="text" disabled="disabled"  class="form-control" value="{{$user->name}}" name="name" placeholder=""/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="email" class="col-sm-2 control-label">邮箱</label>
                                <div class="col-sm-10">
                                    <input type="text"  disabled="disabled" class="form-control" value="{{$user->email}}"  name="name" placeholder=""/>
                                </div>
                            </div>

                            <div class="form-group">
                                <label for="password" class="col-sm-2 control-label">新密码</label>
                                <div class="col-sm-10">
                                    <input type="password" id="pwd" class="form-control" required="required"  name="password" minlength="6" maxlength="20"  placeholder="6到12长度"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <label for="password_confirmation" class="col-sm-2 control-label">确认新密码</label>
                                <div class="col-sm-10">
                                    <input type="password" id="pwdAgain"  class="form-control" name="password_confirmation" minlength="6" maxlength="20"  value=""  placeholder="6到12长度"/>
                                </div>
                            </div>
                            <div class="form-group">
                                <div class="col-sm-offset-2 col-sm-10">
                                    <input type="hidden"  class="form-control"  name="id" value="{{ $user->id }}"/>
                                    <button type="submit" class="btn btn-success btn-block">修改密码</button>
                                </div>
                            </div>
                        </form>
                </div>
            </div>



@endsection

@section('script')
    <script type="text/javascript" src="{{ asset('plugin/validation/dist/js/formValidation.js')}}"></script>
    <script type="text/javascript" src="{{ asset('plugin/validation/dist/js/framework/bootstrap.js')}}"></script>
    <script type="text/javascript" src="{{ asset('plugin/validation/dist/js/language/zh_CN.js')}}"></script>
    <script type="text/javascript">
        $(document).ready(function() {
            // Generate a simple captcha
//            function randomNumber(min, max) {
//                return Math.floor(Math.random() * (max - min + 1) + min);
//            };
//            $('#captchaOperation').html([randomNumber(1, 100), '+', randomNumber(1, 200), '='].join(' '));

            $('#validateForm').formValidation({
                message: '值验证失败',
                icon: {
                    valid: 'glyphicon glyphicon-ok',
                    invalid: 'glyphicon glyphicon-remove',
                    validating: 'glyphicon glyphicon-refresh'
                },
                fields: {
                    name: {
                        validators: {
                            notEmpty: {
                                message: '姓名不能为空'
                            },
                            regexp: {
                                regexp: /^[A-Za-z0-9\u4e00-\u9fa5]{1,10}$/,
                                message: '姓名格式错误'
                            }

                        }
                    },
                    email: {
                        validators: {
                            notEmpty: {
                                message: '电子邮件不能为空'
                            },
                            emailAddress: {
                                message: '请输入有效的电子邮件地址'
                            }
                        }
                    },

                    password: {
                        validators: {
                            notEmpty: {
                                message: '密码不能为空'
                            }
                        }
                    },
                    password_confirmation: {
                        validators: {
                            notEmpty: {
                                message: '确认密码不能为空'
                            },
                            identical: {
                                field: 'password',
                                message: '两次密码输入不一致'
                            }
                        }
                    },


                }
            });
        });
    </script>
@endsection
